{include file="public/header" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}
{load href="__PLUGINS__laydate/laydate.js"}
<!-- 加载编辑器的容器 -->
{:ueditor()}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <form class="form-horizontal" method="post">
            <div class="col-sm-12">
                <div class="ibox-content">

                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目：</label>
                        <div class="col-sm-2">
                            <select class="form-control" name="cate_id">
                                <option value="">选择栏目</option>
                                {php}
                                if(isset($name)){
                                $typeidname=$name['cate_id'];
                                }else{
                                $typeidname='';
                                }
                                {/php}
                                {volist name='typeid' id='v'}
                                <option value="{$v.id}" <?php if($v['id']==$typeidname){echo ' selected="selected"';}?>>{$v.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <!--<div class="form-group">
                        <label class="col-sm-2 control-label">发布人id：</label>
                        <div class="col-sm-6">
                            <input name="user_id" type="text" class="form-control" value="{present name='name'}{$name.user_id}{/present}">
                        </div>
                    </div>-->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">名称：</label>
                        <div class="col-sm-6">
                            <input name="name" type="text" class="form-control" value="{present name='name'}{$name.name}{/present}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">来源：</label>
                        <div class="col-sm-6">
                            <input name="url" type="text" class="form-control" value="{present name='name'}{$name.url}{/present}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">简介：</label>
                        <div class="col-sm-6">
                            <input name="description" type="text" class="form-control" value="{present name='name'}{$name.description}{/present}">
                        </div>
                    </div>
                    <!--<div class="form-group">
                        <label class="col-sm-2 control-label">缩略图：</label>
                        <div class="col-sm-6">
                            <div class="input-group">
                                <input name="image" type="text"  id="image" class="form-control" value="{present name="name"}{$name.image}{/present}">
                                <span class="input-group-btn">
                                    <button type="button" class="btn btn-primary" id="tubiao">上传图片</button>
                                </span>
                            </div>
                            <div class="help-block m-b-none">图片建议统一尺寸</div>
                        </div>
                    </div>-->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">缩略图：</label>
                        <div class="col-sm-9">
                            <div class="input-group">
                                <img src="{present name='name.image'}{if condition="$name.image"}__ROOT__{$name.image}{else /}__IMG__add_img.png{/if}{else /}__IMG__add_img.png{/present}" id="imageimg" style="max-width: 90%;max-height: 500px">
                                <input name="image" type="hidden"  id="image" class="form-control" value="{present name="name"}{$name.image}{/present}" >
                                <span class="input-group-btn">
                                    <button type="button" class="btn btn-primary" id="tubiao">上传图片</button>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">图片集：</label>
                        <div class="col-sm-9">
                            <div id="demo"></div>
                        </div>
                    </div>
                    <input name="images" id="images" type="hidden" class="form-control" value="">
                    <style type="text/css">
                        .meiyouuimmag{
                            margin-bottom: 20px;
                            height:284px;
                            overflow: hidden;
                        }
                        .meiyouuimmag div{
                            width: 100%;
                            margin-bottom: 10px;
                            overflow:hidden;
                            height: 200px
                        }
                        .meiyouuimmag div img{
                            width: 100%
                        }
                        .meiyouuimmag button{
                            position: absolute;
                            right: 15px;
                            display: block;
                        }
                        #imagasdasd{
                            margin-left: 100px;
                            margin-right: 100px;
                        }
                    </style>
                    <div class="form-group" id="imagasdasd">
                        {present name="name"}
                        {php}$imagesdata=json_decode($name['images'],TRUE);$k=0;if($imagesdata){{/php}
                        {foreach $imagesdata as $v}
                        <div class="col-md-3 col-sm-4 col-xs-6 meiyouuimmag" id="id{$k}">
                            <button type="button" class="btn btn btn-sm btn-danger" onclick="delImg({$k})">删除</button>
                            <div><img src="__ROOT__{$v}" >  </div>
                            <textarea data-img="{$v}" style="resize:none" class="form-control" rows="3"></textarea>
                        </div>
                        <?php $k++;?>
                        {/foreach}
                        {php}}{/php}
                        {/present}
                    </div>
                    <!-- 引用控制层插件样式 -->
                    {load href="__PLUGINS__zyUpload/zyUpload.css"}
                    <!-- 引用核心层插件 -->
                    {load href="__PLUGINS__zyUpload/zyUpload.js"}
                    <!-- 引用初始化JS -->
                    <script type="text/javascript">var urlupload="{:url('index/uploads')}";var root = '__ROOT__'</script>
                    {load href="__PLUGINS__zyUpload/script.js"}

                    <div class="form-group">
                        <label class="col-sm-2 control-label">库存：</label>
                        <div class="col-sm-2">
                            <input name="stock" type="text" class="form-control" placeholder="" value="{present name='name'}{$name.stock}{else /}1{/present}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')">
                        </div>
                        <div class="help-block m-b-none">当用户成功下单付款1件商品，数量自动减少1件。  0表示无货。 若填写多规格的数量则自动统计库存数量</div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">默认价格：</label>
                        <div class="col-sm-2">
                            <input name="price" type="text" class="form-control" placeholder="" value="{present name='name'}{:_money($name['price'])}{/present}" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">运费：</label>
                        <div class="col-sm-2">
                            <input name="postage" type="text" class="form-control" placeholder="" value="{present name='name'}{:_money($name['postage'])}{/present}" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">可选规格：</label>
                        <div class="col-sm-10">
                                {present name='name'}
                                {volist name="name.skus" id="sku"}
                            <div style="display: flex;">
                                <div>
                                    <input name="skuname[]" type="text" class="form-control" autocomplete="off" placeholder="规格名称" value="{$sku['name']}" >
                                </div>
                                <div style="font-size: 26px;"> - </div>
                                <div>
                                    <input name="skuprice[]" type="number" class="form-control" placeholder="价格 不填写则为默认价格" value="{$sku['price']}" >
                                </div>
                                <div style="font-size: 26px;"> - </div>
                                <div>
                                    <input name="skustock[]" type="number" class="form-control" placeholder="库存数量" value="{$sku['stock']}" >
                                </div>
                                <div class="btn btn-danger" onclick="delsku(this)">删除该规格</div>
                            </div>
                                {/volist}
                                {/present}
                            
                            <div id="addskubtn">
                                <div class="btn btn-primary" onclick="addsku()">添加新规格</div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">推荐性别：</label>
                        <div class="col-sm-2">
                            <div class="radio i-checks">
                                <label>
                                    <input type="radio" value="" name="rec_sex" {present name="name"}{eq name="name.rec_sex" value=""}checked{/eq}{else /}checked{/present}>不限
                                </label>
                                <label>
                                    <input type="radio" value="男" name="rec_sex" {present name="name"}{eq name="name.rec_sex" value="男"}checked{/eq}{/present}>男
                                </label>
                                <label>
                                    <input type="radio" value="女" name="rec_sex" {present name="name"}{eq name="name.rec_sex" value="女"}checked{/eq}{/present}>女
                                </label>
                            </div>
                        </div>
                        <div class="help-block m-b-none">性别或年龄限制至少选择或填写一个才进入推荐列表</div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">推荐最小年龄：</label>
                        <div class="col-sm-2">
                            <input name="rec_age_min" type="number" class="form-control" placeholder="" value="{present name='name'}{$name['rec_age_min']}{/present}" >
                        </div>
                        <div class="help-block m-b-none">不填写则无下限</div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">推荐最大年龄：</label>
                        <div class="col-sm-2">
                            <input name="rec_age_max" type="number" class="form-control" placeholder="" value="{present name='name'}{$name['rec_age_max']}{/present}" >
                        </div>
                        <div class="help-block m-b-none">不填写则无上限</div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">包邮：</label>
                        <div class="col-sm-4">
                            <div class="radio i-checks">
                                <label>
                                    <input type="radio" value="0" name="is_postage" {present name="name"}{eq name="name.is_postage" value="0"}checked{/eq}{else /}checked{/present}>否
                                </label>
                                <label>
                                    <input type="radio" value="1" name="is_postage" {present name="name"}{eq name="name.is_postage" value="1"}checked{/eq}{/present}>是
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">状态：</label>
                        <div class="col-sm-4">
                            <div class="radio i-checks">
                                <label>
                                    <input type="radio" value="0" name="is_hidden" {present name="name"}{eq name="name.is_hidden" value="0"}checked{/eq}{else /}checked{/present}>上架
                                </label>
                                <label>
                                    <input type="radio" value="1" name="is_hidden" {present name="name"}{eq name="name.is_hidden" value="1"}checked{/eq}{/present}>下架
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">返利：</label>
                        <div class="col-sm-4">
                            <div class="radio i-checks">
                                <label>
                                    <input type="radio" value="0" name="fanli" {present name="name"}{eq name="name.fanli" value="0"}checked{/eq}{else /}checked{/present}>关闭
                                </label>
                                <label>
                                    <input type="radio" value="1" name="fanli" {present name="name"}{eq name="name.fanli" value="1"}checked{/eq}{/present}>开启
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">返利比率(%)：</label>
                        <div class="col-sm-2">
                            <input name="fanli_rate" type="number" class="form-control" value="{present name='name'}{$name.fanli_rate}{else }0{/present}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">返利期限：</label>
                        <div class="col-sm-4">
                            <div class="radio i-checks">
                                <label>
                                    <input type="radio" value="365" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="365"}checked{/eq}{else /}checked{/present}>一年
                                </label>
                                <label>
                                    <input type="radio" value="730" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="730"}checked{/eq}{/present}>两年
                                </label>
                                <label>
                                    <input type="radio" value="1095" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="1095"}checked{/eq}{/present}>三年
                                </label>
                                <label>
                                    <input type="radio" value="1460" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="1460"}checked{/eq}{/present}>四年
                                </label>
                                <label>
                                    <input type="radio" value="1825" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="1825"}checked{/eq}{/present}>五年
                                </label>
                                <label>
                                    <input type="radio" value="2190" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="2190"}checked{/eq}{/present}>六年
                                </label>
                                <label>
                                    <input type="radio" value="2555" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="2555"}checked{/eq}{/present}>七年
                                </label>
                                <label>
                                    <input type="radio" value="2920" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="2920"}checked{/eq}{/present}>八年
                                </label>
                                <label>
                                    <input type="radio" value="3285" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="3285"}checked{/eq}{/present}>九年
                                </label>
                                <label>
                                    <input type="radio" value="3650" name="fanli_day" {present name="name"}{eq name="name.fanli_day" value="3650"}checked{/eq}{/present}>十年
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">排序：</label>
                        <div class="col-sm-2">
                            <input name="sort" type="text" class="form-control" value="{present name='name'}{$name.sort}{else }0{/present}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">详情：</label>
                        <div class="col-sm-9">
                            <script type="text/plain" id="content" name="detail" style="width:100%;height:240px;">
{present name="name"}{$name['detail']}{/present}

</script>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    $(document).ready(function(){
        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        })
    });
    function msg(){
        layer.msg("上传成功")
    }
    function time(){
        laydate(
            {
                fixed: false,
                istime: true,
                format: 'YYYY-MM-DD hh:mm:ss',
                zIndex: 999999999999,
                isclear: false,
            }
        )
    }
    function delImg(id){
        $('#id'+id).remove();
    }

    function addsku() {
        let html = `
            <div style="display: flex; margin-top: 5px;">
                <div>
                    <input name="skuname[]" type="text" class="form-control" autocomplete="off" placeholder="规格名称" value="" >
                </div>
                <div style="font-size: 26px;"> - </div>
                <div>
                    <input name="skuprice[]" type="number" class="form-control" placeholder="价格 不填写则为默认价格" value="" >
                </div>
                <div style="font-size: 26px;"> - </div>
                <div>
                    <input name="skustock[]" type="number" class="form-control" placeholder="数量" value="" >
                </div>
                <div class="btn btn-danger" onclick="delsku(this)">删除该规格</div>
            </div>`
        $("#addskubtn").before(html);
    }

    function delsku(that) {
        $(that).parent().remove()
    }
</script>
{include file="public/bottom" /}
